<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Platform Security Architecture — cryptography and keystore interface: psa/crypto_sizes.h File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Platform Security Architecture — cryptography and keystore interface
   &#160;<span id="projectnumber">Working draft</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_7dae9cfde651cd3cb034485ce5e391b9.html">psa</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#define-members">Macros</a>  </div>
  <div class="headertitle">
<div class="title">crypto_sizes.h File Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>PSA cryptography module: Mbed TLS buffer size macros.  
<a href="#details">More...</a></p>
<div class="textblock"><code>#include &quot;../mbedtls/config.h&quot;</code><br />
</div><div class="textblock"><div class="dynheader">
Include dependency graph for crypto_sizes.h:</div>
<div class="dyncontent">
<div class="center"><img src="crypto__sizes_8h__incl.png" border="0" usemap="#psa_2crypto__sizes_8h" alt=""/></div>
<map name="psa_2crypto__sizes_8h" id="psa_2crypto__sizes_8h">
</map>
</div>
</div><div class="textblock"><div class="dynheader">
This graph shows which files directly or indirectly include this file:</div>
<div class="dyncontent">
<div class="center"><img src="crypto__sizes_8h__dep__incl.png" border="0" usemap="#psa_2crypto__sizes_8hdep" alt=""/></div>
<map name="psa_2crypto__sizes_8hdep" id="psa_2crypto__sizes_8hdep">
<area shape="rect" id="node2" href="crypto_8h.html" title="Platform Security Architecture cryptography module. " alt="" coords="24,80,119,107"/>
</map>
</div>
</div>
<p><a href="crypto__sizes_8h_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:a6ce1014efbbc0bcca286ef7f9a72cb29"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="crypto__sizes_8h.html#a6ce1014efbbc0bcca286ef7f9a72cb29">PSA_HASH_MAX_SIZE</a>&#160;&#160;&#160;64</td></tr>
<tr class="separator:a6ce1014efbbc0bcca286ef7f9a72cb29"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a123539632874601194b1d86a398e14ff"><td class="memItemLeft" align="right" valign="top"><a id="a123539632874601194b1d86a398e14ff"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>PSA_HMAC_MAX_HASH_BLOCK_SIZE</b>&#160;&#160;&#160;128</td></tr>
<tr class="separator:a123539632874601194b1d86a398e14ff"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a4681cc4f6226883a2160122c562ca682"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="crypto__sizes_8h.html#a4681cc4f6226883a2160122c562ca682">PSA_MAC_MAX_SIZE</a>&#160;&#160;&#160;<a class="el" href="crypto__sizes_8h.html#a6ce1014efbbc0bcca286ef7f9a72cb29">PSA_HASH_MAX_SIZE</a></td></tr>
<tr class="separator:a4681cc4f6226883a2160122c562ca682"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2ab9324235c63e9e8cdee5bb1793eabe"><td class="memItemLeft" align="right" valign="top"><a id="a2ab9324235c63e9e8cdee5bb1793eabe"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>PSA_VENDOR_RSA_MAX_KEY_BITS</b>&#160;&#160;&#160;4096</td></tr>
<tr class="separator:a2ab9324235c63e9e8cdee5bb1793eabe"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a81080a6cbbab87f35b114cb991e3f550"><td class="memItemLeft" align="right" valign="top"><a id="a81080a6cbbab87f35b114cb991e3f550"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>PSA_VENDOR_ECC_MAX_CURVE_BITS</b>&#160;&#160;&#160;521</td></tr>
<tr class="separator:a81080a6cbbab87f35b114cb991e3f550"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad755101764dba14589e5919ee41be7ca"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="crypto__sizes_8h.html#ad755101764dba14589e5919ee41be7ca">PSA_ASYMMETRIC_SIGNATURE_MAX_SIZE</a></td></tr>
<tr class="separator:ad755101764dba14589e5919ee41be7ca"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa84c5fb384ac7cb1bfc52adde96588ee"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="crypto__sizes_8h.html#aa84c5fb384ac7cb1bfc52adde96588ee">PSA_MAC_FINAL_SIZE</a>(key_type,  key_bits,  alg)</td></tr>
<tr class="separator:aa84c5fb384ac7cb1bfc52adde96588ee"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a85667d47a7aa6c7b99a80e5273671266"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="crypto__sizes_8h.html#a85667d47a7aa6c7b99a80e5273671266">PSA_AEAD_ENCRYPT_OUTPUT_SIZE</a>(alg,  plaintext_length)</td></tr>
<tr class="separator:a85667d47a7aa6c7b99a80e5273671266"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1d057796166c16eb673ad1997e48a60b"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="crypto__sizes_8h.html#a1d057796166c16eb673ad1997e48a60b">PSA_AEAD_DECRYPT_OUTPUT_SIZE</a>(alg,  ciphertext_length)</td></tr>
<tr class="separator:a1d057796166c16eb673ad1997e48a60b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a77565b9b4fe6d8730fd2120f4c8378ab"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="crypto__sizes_8h.html#a77565b9b4fe6d8730fd2120f4c8378ab">PSA_ASYMMETRIC_SIGN_OUTPUT_SIZE</a>(key_type,  key_bits,  alg)</td></tr>
<tr class="separator:a77565b9b4fe6d8730fd2120f4c8378ab"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a66ba3bd93e5ec52870ccc3848778bad8"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="crypto__sizes_8h.html#a66ba3bd93e5ec52870ccc3848778bad8">PSA_ASYMMETRIC_ENCRYPT_OUTPUT_SIZE</a>(key_type,  key_bits,  alg)</td></tr>
<tr class="separator:a66ba3bd93e5ec52870ccc3848778bad8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a61a246f3eac41989821d982e56fea6c1"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="crypto__sizes_8h.html#a61a246f3eac41989821d982e56fea6c1">PSA_ASYMMETRIC_DECRYPT_OUTPUT_SIZE</a>(key_type,  key_bits,  alg)</td></tr>
<tr class="separator:a61a246f3eac41989821d982e56fea6c1"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>PSA cryptography module: Mbed TLS buffer size macros. </p>
<dl class="section note"><dt>Note</dt><dd>This file may not be included directly. Applications must include <a class="el" href="crypto_8h.html" title="Platform Security Architecture cryptography module. ">psa/crypto.h</a>.</dd></dl>
<p>This file contains the definitions of macros that are useful to compute buffer sizes. The signatures and semantics of these macros are standardized, but the definitions are not, because they depend on the available algorithms and, in some cases, on permitted tolerances on buffer sizes.</p>
<p>In implementations with isolation between the application and the cryptography module, implementers should take care to ensure that the definitions that are exposed to applications match what the module implements.</p>
<p>Macros that compute sizes whose values do not depend on the implementation are in <a class="el" href="crypto_8h.html" title="Platform Security Architecture cryptography module. ">crypto.h</a>. </p>
</div><h2 class="groupheader">Macro Definition Documentation</h2>
<a id="a1d057796166c16eb673ad1997e48a60b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a1d057796166c16eb673ad1997e48a60b">&#9670;&nbsp;</a></span>PSA_AEAD_DECRYPT_OUTPUT_SIZE</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define PSA_AEAD_DECRYPT_OUTPUT_SIZE</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">alg, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">ciphertext_length&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<b>Value:</b><div class="fragment"><div class="line">(<a class="code" href="group__aead.html#ga337ef01fe3c9f71d62ccced33e8917f4">PSA_AEAD_TAG_SIZE</a>(alg) != 0 ?                              \</div><div class="line">     (plaintext_length) - <a class="code" href="group__aead.html#ga337ef01fe3c9f71d62ccced33e8917f4">PSA_AEAD_TAG_SIZE</a>(alg) :              \</div><div class="line">     0)</div><div class="ttc" id="group__aead_html_ga337ef01fe3c9f71d62ccced33e8917f4"><div class="ttname"><a href="group__aead.html#ga337ef01fe3c9f71d62ccced33e8917f4">PSA_AEAD_TAG_SIZE</a></div><div class="ttdeci">#define PSA_AEAD_TAG_SIZE(alg)</div><div class="ttdef"><b>Definition:</b> crypto.h:2197</div></div>
</div><!-- fragment --><p>The maximum size of the output of <a class="el" href="group__aead.html#ga5b88ad2cfbf2e98039858416fa3ebd7a">psa_aead_decrypt()</a>, in bytes.</p>
<p>If the size of the plaintext buffer is at least this large, it is guaranteed that <a class="el" href="group__aead.html#ga5b88ad2cfbf2e98039858416fa3ebd7a">psa_aead_decrypt()</a> will not fail due to an insufficient buffer size. Depending on the algorithm, the actual size of the plaintext may be smaller.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">alg</td><td>An AEAD algorithm (<code>PSA_ALG_XXX</code> value such that <a class="el" href="group__crypto__types.html#ga1d44829d60065eaa4ac9a703e7d6abc8">PSA_ALG_IS_AEAD(alg)</a> is true). </td></tr>
    <tr><td class="paramname">ciphertext_length</td><td>Size of the plaintext in bytes.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The AEAD ciphertext size for the specified algorithm. If the AEAD algorithm is not recognized, return 0. An implementation may return either 0 or a correct size for an AEAD algorithm that it recognizes, but does not support. </dd></dl>

</div>
</div>
<a id="a85667d47a7aa6c7b99a80e5273671266"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a85667d47a7aa6c7b99a80e5273671266">&#9670;&nbsp;</a></span>PSA_AEAD_ENCRYPT_OUTPUT_SIZE</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define PSA_AEAD_ENCRYPT_OUTPUT_SIZE</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">alg, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">plaintext_length&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<b>Value:</b><div class="fragment"><div class="line">(<a class="code" href="group__aead.html#ga337ef01fe3c9f71d62ccced33e8917f4">PSA_AEAD_TAG_SIZE</a>(alg) != 0 ?                              \</div><div class="line">     (plaintext_length) + <a class="code" href="group__aead.html#ga337ef01fe3c9f71d62ccced33e8917f4">PSA_AEAD_TAG_SIZE</a>(alg) :              \</div><div class="line">     0)</div><div class="ttc" id="group__aead_html_ga337ef01fe3c9f71d62ccced33e8917f4"><div class="ttname"><a href="group__aead.html#ga337ef01fe3c9f71d62ccced33e8917f4">PSA_AEAD_TAG_SIZE</a></div><div class="ttdeci">#define PSA_AEAD_TAG_SIZE(alg)</div><div class="ttdef"><b>Definition:</b> crypto.h:2197</div></div>
</div><!-- fragment --><p>The maximum size of the output of <a class="el" href="group__aead.html#ga14e4068a3d328515a4884f3037904d54">psa_aead_encrypt()</a>, in bytes.</p>
<p>If the size of the ciphertext buffer is at least this large, it is guaranteed that <a class="el" href="group__aead.html#ga14e4068a3d328515a4884f3037904d54">psa_aead_encrypt()</a> will not fail due to an insufficient buffer size. Depending on the algorithm, the actual size of the ciphertext may be smaller.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">alg</td><td>An AEAD algorithm (<code>PSA_ALG_XXX</code> value such that <a class="el" href="group__crypto__types.html#ga1d44829d60065eaa4ac9a703e7d6abc8">PSA_ALG_IS_AEAD(alg)</a> is true). </td></tr>
    <tr><td class="paramname">plaintext_length</td><td>Size of the plaintext in bytes.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The AEAD ciphertext size for the specified algorithm. If the AEAD algorithm is not recognized, return 0. An implementation may return either 0 or a correct size for an AEAD algorithm that it recognizes, but does not support. </dd></dl>

</div>
</div>
<a id="a61a246f3eac41989821d982e56fea6c1"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a61a246f3eac41989821d982e56fea6c1">&#9670;&nbsp;</a></span>PSA_ASYMMETRIC_DECRYPT_OUTPUT_SIZE</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define PSA_ASYMMETRIC_DECRYPT_OUTPUT_SIZE</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">key_type, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">key_bits, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">alg&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<b>Value:</b><div class="fragment"><div class="line">(<a class="code" href="group__crypto__types.html#ga0e1d8f241228e49c9cadadfb4579ef1a">PSA_KEY_TYPE_IS_RSA</a>(key_type) ?                                    \</div><div class="line">     PSA_BITS_TO_BYTES(key_bits) - PSA_RSA_MINIMUM_PADDING_SIZE(alg) :  \</div><div class="line">     0)</div><div class="ttc" id="group__crypto__types_html_ga0e1d8f241228e49c9cadadfb4579ef1a"><div class="ttname"><a href="group__crypto__types.html#ga0e1d8f241228e49c9cadadfb4579ef1a">PSA_KEY_TYPE_IS_RSA</a></div><div class="ttdeci">#define PSA_KEY_TYPE_IS_RSA(type)</div><div class="ttdef"><b>Definition:</b> crypto.h:463</div></div>
</div><!-- fragment --><p>Safe output buffer size for <a class="el" href="group__asymmetric.html#ga3094be979f37aa2865c283167ba907e6" title="Decrypt a short message with a private key. ">psa_asymmetric_decrypt()</a>.</p>
<p>This macro returns a safe buffer size for a ciphertext produced using a key of the specified type and size, with the specified algorithm. Note that the actual size of the ciphertext may be smaller, depending on the algorithm.</p>
<dl class="section warning"><dt>Warning</dt><dd>This function may call its arguments multiple times or zero times, so you should not pass arguments that contain side effects.</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">key_type</td><td>An asymmetric key type (this may indifferently be a key pair type or a public key type). </td></tr>
    <tr><td class="paramname">key_bits</td><td>The size of the key in bits. </td></tr>
    <tr><td class="paramname">alg</td><td>The signature algorithm.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>If the parameters are valid and supported, return a buffer size in bytes that guarantees that <a class="el" href="group__asymmetric.html#ga3094be979f37aa2865c283167ba907e6" title="Decrypt a short message with a private key. ">psa_asymmetric_decrypt()</a> will not fail with <a class="el" href="group__basic.html#ga695025f4ec11249aee7ea3d0f65e01c8">PSA_ERROR_BUFFER_TOO_SMALL</a>. If the parameters are a valid combination that is not supported by the implementation, this macro either shall return either a sensible size or 0. If the parameters are not valid, the return value is unspecified. </dd></dl>

</div>
</div>
<a id="a66ba3bd93e5ec52870ccc3848778bad8"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a66ba3bd93e5ec52870ccc3848778bad8">&#9670;&nbsp;</a></span>PSA_ASYMMETRIC_ENCRYPT_OUTPUT_SIZE</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define PSA_ASYMMETRIC_ENCRYPT_OUTPUT_SIZE</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">key_type, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">key_bits, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">alg&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<b>Value:</b><div class="fragment"><div class="line">(<a class="code" href="group__crypto__types.html#ga0e1d8f241228e49c9cadadfb4579ef1a">PSA_KEY_TYPE_IS_RSA</a>(key_type) ?                                    \</div><div class="line">     ((void)alg, PSA_BITS_TO_BYTES(key_bits)) :                         \</div><div class="line">     0)</div><div class="ttc" id="group__crypto__types_html_ga0e1d8f241228e49c9cadadfb4579ef1a"><div class="ttname"><a href="group__crypto__types.html#ga0e1d8f241228e49c9cadadfb4579ef1a">PSA_KEY_TYPE_IS_RSA</a></div><div class="ttdeci">#define PSA_KEY_TYPE_IS_RSA(type)</div><div class="ttdef"><b>Definition:</b> crypto.h:463</div></div>
</div><!-- fragment --><p>Safe output buffer size for <a class="el" href="group__asymmetric.html#ga3c0ba402bac217d623dba8320c2240c2" title="Encrypt a short message with a public key. ">psa_asymmetric_encrypt()</a>.</p>
<p>This macro returns a safe buffer size for a ciphertext produced using a key of the specified type and size, with the specified algorithm. Note that the actual size of the ciphertext may be smaller, depending on the algorithm.</p>
<dl class="section warning"><dt>Warning</dt><dd>This function may call its arguments multiple times or zero times, so you should not pass arguments that contain side effects.</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">key_type</td><td>An asymmetric key type (this may indifferently be a key pair type or a public key type). </td></tr>
    <tr><td class="paramname">key_bits</td><td>The size of the key in bits. </td></tr>
    <tr><td class="paramname">alg</td><td>The signature algorithm.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>If the parameters are valid and supported, return a buffer size in bytes that guarantees that <a class="el" href="group__asymmetric.html#ga3c0ba402bac217d623dba8320c2240c2" title="Encrypt a short message with a public key. ">psa_asymmetric_encrypt()</a> will not fail with <a class="el" href="group__basic.html#ga695025f4ec11249aee7ea3d0f65e01c8">PSA_ERROR_BUFFER_TOO_SMALL</a>. If the parameters are a valid combination that is not supported by the implementation, this macro either shall return either a sensible size or 0. If the parameters are not valid, the return value is unspecified. </dd></dl>

</div>
</div>
<a id="a77565b9b4fe6d8730fd2120f4c8378ab"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a77565b9b4fe6d8730fd2120f4c8378ab">&#9670;&nbsp;</a></span>PSA_ASYMMETRIC_SIGN_OUTPUT_SIZE</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define PSA_ASYMMETRIC_SIGN_OUTPUT_SIZE</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">key_type, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">key_bits, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">alg&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<b>Value:</b><div class="fragment"><div class="line">(<a class="code" href="group__crypto__types.html#ga0e1d8f241228e49c9cadadfb4579ef1a">PSA_KEY_TYPE_IS_RSA</a>(key_type) ? ((void)alg, PSA_BITS_TO_BYTES(key_bits)) : \</div><div class="line">     <a class="code" href="group__crypto__types.html#ga88e01fa06b585654689a99bcc06bbe66">PSA_KEY_TYPE_IS_ECC</a>(key_type) ? <a class="code" href="group__asymmetric.html#ga10c472a35f04051add6b20cc228ffc11">PSA_ECDSA_SIGNATURE_SIZE</a>(key_bits) : \</div><div class="line">     ((void)alg, 0))</div><div class="ttc" id="group__crypto__types_html_ga0e1d8f241228e49c9cadadfb4579ef1a"><div class="ttname"><a href="group__crypto__types.html#ga0e1d8f241228e49c9cadadfb4579ef1a">PSA_KEY_TYPE_IS_RSA</a></div><div class="ttdeci">#define PSA_KEY_TYPE_IS_RSA(type)</div><div class="ttdef"><b>Definition:</b> crypto.h:463</div></div>
<div class="ttc" id="group__asymmetric_html_ga10c472a35f04051add6b20cc228ffc11"><div class="ttname"><a href="group__asymmetric.html#ga10c472a35f04051add6b20cc228ffc11">PSA_ECDSA_SIGNATURE_SIZE</a></div><div class="ttdeci">#define PSA_ECDSA_SIGNATURE_SIZE(curve_bits)</div><div class="ttdoc">ECDSA signature size for a given curve bit size. </div><div class="ttdef"><b>Definition:</b> crypto.h:2322</div></div>
<div class="ttc" id="group__crypto__types_html_ga88e01fa06b585654689a99bcc06bbe66"><div class="ttname"><a href="group__crypto__types.html#ga88e01fa06b585654689a99bcc06bbe66">PSA_KEY_TYPE_IS_ECC</a></div><div class="ttdeci">#define PSA_KEY_TYPE_IS_ECC(type)</div><div class="ttdef"><b>Definition:</b> crypto.h:467</div></div>
</div><!-- fragment --><p>Safe signature buffer size for <a class="el" href="group__asymmetric.html#ga48091460d1ead078d93caa3611aec976" title="Sign a hash or short message with a private key. ">psa_asymmetric_sign()</a>.</p>
<p>This macro returns a safe buffer size for a signature using a key of the specified type and size, with the specified algorithm. Note that the actual size of the signature may be smaller (some algorithms produce a variable-size signature).</p>
<dl class="section warning"><dt>Warning</dt><dd>This function may call its arguments multiple times or zero times, so you should not pass arguments that contain side effects.</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">key_type</td><td>An asymmetric key type (this may indifferently be a key pair type or a public key type). </td></tr>
    <tr><td class="paramname">key_bits</td><td>The size of the key in bits. </td></tr>
    <tr><td class="paramname">alg</td><td>The signature algorithm.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>If the parameters are valid and supported, return a buffer size in bytes that guarantees that <a class="el" href="group__asymmetric.html#ga48091460d1ead078d93caa3611aec976" title="Sign a hash or short message with a private key. ">psa_asymmetric_sign()</a> will not fail with <a class="el" href="group__basic.html#ga695025f4ec11249aee7ea3d0f65e01c8">PSA_ERROR_BUFFER_TOO_SMALL</a>. If the parameters are a valid combination that is not supported by the implementation, this macro either shall return either a sensible size or 0. If the parameters are not valid, the return value is unspecified. </dd></dl>

</div>
</div>
<a id="ad755101764dba14589e5919ee41be7ca"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad755101764dba14589e5919ee41be7ca">&#9670;&nbsp;</a></span>PSA_ASYMMETRIC_SIGNATURE_MAX_SIZE</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define PSA_ASYMMETRIC_SIGNATURE_MAX_SIZE</td>
        </tr>
      </table>
</div><div class="memdoc">
<b>Value:</b><div class="fragment"><div class="line">PSA_BITS_TO_BYTES(                                                  \</div><div class="line">        PSA_VENDOR_RSA_MAX_KEY_BITS &gt; PSA_VENDOR_ECC_MAX_CURVE_BITS ?   \</div><div class="line">        PSA_VENDOR_RSA_MAX_KEY_BITS :                                   \</div><div class="line">        PSA_VENDOR_ECC_MAX_CURVE_BITS                                   \</div><div class="line">        )</div></div><!-- fragment --><p>Maximum size of an asymmetric signature.</p>
<p>This macro must expand to a compile-time constant integer. This value should be the maximum size of a MAC supported by the implementation, in bytes, and must be no smaller than this maximum. </p>

</div>
</div>
<a id="a6ce1014efbbc0bcca286ef7f9a72cb29"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a6ce1014efbbc0bcca286ef7f9a72cb29">&#9670;&nbsp;</a></span>PSA_HASH_MAX_SIZE</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define PSA_HASH_MAX_SIZE&#160;&#160;&#160;64</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Maximum size of a hash.</p>
<p>This macro must expand to a compile-time constant integer. This value should be the maximum size of a hash supported by the implementation, in bytes, and must be no smaller than this maximum. </p>

</div>
</div>
<a id="aa84c5fb384ac7cb1bfc52adde96588ee"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa84c5fb384ac7cb1bfc52adde96588ee">&#9670;&nbsp;</a></span>PSA_MAC_FINAL_SIZE</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define PSA_MAC_FINAL_SIZE</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">key_type, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">key_bits, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">alg&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<b>Value:</b><div class="fragment"><div class="line">(<a class="code" href="group__crypto__types.html#ga4a050c3c3cbc6eb96418f18847601c8a">PSA_ALG_IS_HMAC</a>(alg) ? <a class="code" href="group__hash.html#gaef340331ce3cba2b57e1fc5624bf1f99">PSA_HASH_SIZE</a>(PSA_ALG_HMAC_HASH(alg)) : \</div><div class="line">     PSA_ALG_IS_BLOCK_CIPHER_MAC(alg) ? <a class="code" href="group__crypto__types.html#gacaa366bdeb0413e63e87a667c5457b2e">PSA_BLOCK_CIPHER_BLOCK_SIZE</a>(key_type) : \</div><div class="line">     0)</div><div class="ttc" id="group__crypto__types_html_gacaa366bdeb0413e63e87a667c5457b2e"><div class="ttname"><a href="group__crypto__types.html#gacaa366bdeb0413e63e87a667c5457b2e">PSA_BLOCK_CIPHER_BLOCK_SIZE</a></div><div class="ttdeci">#define PSA_BLOCK_CIPHER_BLOCK_SIZE(type)</div><div class="ttdef"><b>Definition:</b> crypto.h:544</div></div>
<div class="ttc" id="group__hash_html_gaef340331ce3cba2b57e1fc5624bf1f99"><div class="ttname"><a href="group__hash.html#gaef340331ce3cba2b57e1fc5624bf1f99">PSA_HASH_SIZE</a></div><div class="ttdeci">#define PSA_HASH_SIZE(alg)</div><div class="ttdef"><b>Definition:</b> crypto.h:1463</div></div>
<div class="ttc" id="group__crypto__types_html_ga4a050c3c3cbc6eb96418f18847601c8a"><div class="ttname"><a href="group__crypto__types.html#ga4a050c3c3cbc6eb96418f18847601c8a">PSA_ALG_IS_HMAC</a></div><div class="ttdeci">#define PSA_ALG_IS_HMAC(alg)</div><div class="ttdef"><b>Definition:</b> crypto.h:721</div></div>
</div><!-- fragment --><p>The size of the output of <a class="el" href="group__MAC.html#gac22bc0125580c96724a09226cfbc97f2">psa_mac_sign_finish()</a>, in bytes.</p>
<p>This is also the MAC size that <a class="el" href="group__MAC.html#gac92b2930d6728e1be4d011c05d485822">psa_mac_verify_finish()</a> expects.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">key_type</td><td>The type of the MAC key. </td></tr>
    <tr><td class="paramname">key_bits</td><td>The size of the MAC key in bits. </td></tr>
    <tr><td class="paramname">alg</td><td>A MAC algorithm (<code>PSA_ALG_XXX</code> value such that <a class="el" href="group__crypto__types.html#gaca7aee4c9dde316b3b1a150a26eab776">PSA_ALG_IS_MAC(alg)</a> is true).</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The MAC size for the specified algorithm with the specified key parameters. </dd>
<dd>
0 if the MAC algorithm is not recognized. </dd>
<dd>
Either 0 or the correct size for a MAC algorithm that the implementation recognizes, but does not support. </dd>
<dd>
Unspecified if the key parameters are not consistent with the algorithm. </dd></dl>

</div>
</div>
<a id="a4681cc4f6226883a2160122c562ca682"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a4681cc4f6226883a2160122c562ca682">&#9670;&nbsp;</a></span>PSA_MAC_MAX_SIZE</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define PSA_MAC_MAX_SIZE&#160;&#160;&#160;<a class="el" href="crypto__sizes_8h.html#a6ce1014efbbc0bcca286ef7f9a72cb29">PSA_HASH_MAX_SIZE</a></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Maximum size of a MAC.</p>
<p>This macro must expand to a compile-time constant integer. This value should be the maximum size of a MAC supported by the implementation, in bytes, and must be no smaller than this maximum. </p>

</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.13
</small></address>
</body>
</html>
